import 'package:flutter/widgets.dart';

class DelayedWidget extends StatelessWidget {
  const DelayedWidget({
    required this.delay,
    required this.child,
    this.placeholder = const SizedBox(),
    Key? key,
  }) : super(key: key);

  final Duration delay;
  final Widget child;
  final Widget placeholder;

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: Future.delayed(delay, () => 1),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return child;
        }

        return placeholder;
      },
    );
  }
}
